package cn.huangsm.advance.designmode.singlemode;

/**
 * 单例模式----饿汉式
 * @author huang
 * @PACKAGE_NAME cn.huangsm.advance.designmode.singlemode
 * @PROJECT_NAME advance-code
 * @date 2019/1/24
 */
public class HungryType {
    /**
     * 私有化构造方法
     */
     private  HungryType(){};
    /**
     * 在单例类中创建该类的唯一实例对象
     */
    private static HungryType hungryType=new HungryType();
    /**
     * 对外提供一个获取对象的方法
     */
    public static HungryType getHungryType(){
        return hungryType;
    }

    public static void main(String[] args) {
        System.out.println(HungryType.getHungryType());
        System.out.println(HungryType.getHungryType());
        System.out.println(HungryType.getHungryType());
        System.out.println(HungryType.getHungryType());
    }
}
